<?php
/**
 * 微博后台管理项目 媒体表数据层

 */
define("CACHE_jiaodian_COUNT_TUIJIAN_jiaodian","tuijian_jiaodian_");
class db_tuijian_jiaodian extends db_base
{
	var $table_name  ="tuijian_jiaodian";
	
	
	/**
	 * 根据D_ID取数据
	 * @param $d_id
	 */
	function get_list_by_order($p=1,$pcount=10)
	{
		
		$content = $this->get_alllist($this->table_name,$p,$pcount, " `create_time` desc ", $where);

		return $content;
	}
	
	
	function admin_get_one($id)
	{
		$where = "id = $id";
			
		$content = $this->get_alllist($this->table_name,1,1, "", $where);

		return $content[0];
	}
	
	function admin_get_list($status,$p=1,$pcount=10)
	{
		
		if(strlen($status)>0)$where_array[] = " status ={$status} ";
		
			
		$where = join(" and ",	$where_array);
		
		$content = $this->get_alllist($this->table_name,$p,$count, " `create_time` desc", $where);
	

		return $content;
	}
	
	function admin_get_count($status)
	{
		
		if(strlen($status)>0)$where_array[] = " status ={$status} ";
		
		$where = join(" and ",	$where_array);
		
		$content = $this->get_listcount($this->table_name,$where);
	

		return $content;
	}
	
	
	function admin_update_by_id($id,$status="",$pic1="",$pic2="",$title1="",$title2="",$link="")
	{
		$where = "id = $id";
		
		if(strlen($status)>0)$ary["status"] = $status;
		
		if($pic1)$ary["pic1"] = $pic1;
		if($pic2)$ary["pic2"] = $pic2;
		if($title1)$ary["title1"] = $title1;
		if($title2)$ary["title2"] = $title2;
		if($link)$ary["link"] = $link;
		
		
		return $this->update($this->table_name,$ary,$where);
	}
	
	
	function admin_insert_tuijian_jiaodian($pic1,$pic2,$title1,$title2,$link)
	{
		$ary["pic1"] = $pic1;
		$ary["pic2"] = $pic2;
		$ary["title1"] = $title1;
		$ary["title2"] = $title2;
		$ary["link"] = $link;
		$ary["status"] = 1;
		$ary["create_time"] = Date::get_date_time();
		$ary["create_ip"] = IP::get_client_ip_long();
		$ary["create_uid"] = admin::admin_get_login_uid();
		$res = $this->insert($this->table_name,$ary,"",true);
		
		return $res;
		
	}
	
	function cron_insert_tuijian_jiaodian($show_type,$jiaodian_id,$order,$uid,$detail_info)
	{
		$ary["uid"] = $uid;
		$ary["show_type"] = $show_type;
		$ary["order"] = $order;
		$ary["jiaodian_id"] = $jiaodian_id;
		$ary["detail_info"] = $detail_info;
		$ary["status"] = 1;
		$ary["is_tuijian"] = 1;
		$ary["create_time"] = Date::get_date_time();
		$ary["create_ip"] = IP::get_client_ip_long();
	
		$res = $this->insert($this->table_name,$ary,"",true);
		
		return $res;
		
	}
	
	
	function cron_del_tuijian_jiaodian()
	{
		$ary["order"] = "100";
		$res = $this->update($this->table_name,$ary,$where);
		return $res;
		
	}
}
